package com.fita.entity.order;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fita.entity.data.VehicleParameter;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * 
 * @author dan
 *
 */
@Entity
@Table(name = "order_vehicle_fee")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class OrderVehicleFee {
    
    @Id
    @GeneratedValue
    private Long id;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private Order order;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private VehicleParameter vehicleParameter;
    
    /** 描述 */
    private String description;
    
    /** 货币 */
    private String currencyCode;
    
    /** 价钱 */
    private BigDecimal amount;
    
    /** 是否包含 */
    private boolean include;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * 
     */
    public OrderVehicleFee() {
        // TODO Auto-generated constructor stub
    }
    
    /**
     * 
     * @param currencyCode
     * @param amout
     * @param include
     * @param order
     * @param vehicleParameter
     */
    public OrderVehicleFee(String currencyCode, BigDecimal amout, boolean include, Order order, VehicleParameter vehicleParameter) {
        this.currencyCode = currencyCode;
        this.amount = amout;
        this.description = StringUtils.isNotBlank(vehicleParameter.getChineseName()) ? vehicleParameter.getChineseName() : vehicleParameter.getEnglishName();
        this.include = include;
        this.order = order;
        this.vehicleParameter = vehicleParameter;
        this.disabled = false;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the order
     */
    public Order getOrder() {
        return order;
    }

    /**
     * @return the vehicleParameter
     */
    public VehicleParameter getVehicleParameter() {
        return vehicleParameter;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @return the currencyCode
     */
    public String getCurrencyCode() {
        return currencyCode;
    }

    /**
     * @return the amount
     */
    public BigDecimal getAmount() {
        return amount;
    }

    /**
     * @return the include
     */
    public boolean isInclude() {
        return include;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param order the order to set
     */
    public void setOrder(Order order) {
        this.order = order;
    }

    /**
     * @param vehicleParameter the vehicleParameter to set
     */
    public void setVehicleParameter(VehicleParameter vehicleParameter) {
        this.vehicleParameter = vehicleParameter;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @param currencyCode the currencyCode to set
     */
    public void setCurrencyCode(String currencyCode) {
        this.currencyCode = currencyCode;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    /**
     * @param include the include to set
     */
    public void setInclude(boolean include) {
        this.include = include;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
